<?php
// header('Access-Control-Allow-Origin: *');
require_once('./Base.php');
$base = new Base();
$db = $base->getDB();

@$token = $_GET["token"];

if (empty($base->checkToken($token))) {
	exit($base->getResJson(false, null, USER_UNAUTHORIZED_ERROR, '未授权用户'));
}

@$page = $_GET['page'];
if (!isset($page)) {
	$page = 0;
}

@$cid = $_GET['cid'];
if (!isset($cid)) {
	$cid = 0;
}
@$pageSize = $_GET['pageSize'];
// $pageSize = 20;
$start = $pageSize * $page;

$sql = "select count(id) as total from msbd";
$sql2 = "select * from msbd";

if ($cid != 0) {
	$sql .= " where cid = $cid";
	$sql2 .= " where cid = $cid";
}

$sql2 .= " order by id desc limit $start, $pageSize";

$total = $db->rawQuery($sql)[0]['total'];
$list = $db->rawQuery($sql2);

// echo $sql2;

$res = array(
	"success" => true,
	"message" => "接口数据请求成功",
	"errCode" => 0,
	"data" => $list,
	"total" => $total
);

echo $base->getResJson(true, null, 0, '接口数据请求成功', $res);
